package com.wuliu.business.line;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.wuliu.model.line.Line;
import com.wuliu.util.DbPool;

public class LineObj {
	public static Line getLineById(String id){
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		Line line = new Line();
		if(id==null || id.equals(""))
			return line;
		String strsql = "SELECT * FROM WL_LINE WHERE LINE_ID=?";
		try{
			conn = DbPool.getConnection();
			pstmt = conn.prepareStatement(strsql);
			pstmt.setString(1,id);
			rs = pstmt.executeQuery();
			if(rs.next()){
				line.setLineId(rs.getString("LINE_ID"));
				line.setLineName(rs.getString("LINE_NAME"));
				line.setLineCode(rs.getString("LINE_CODE"));
				line.setLineLength(rs.getBigDecimal("LINE_LENGTH"));
				line.setAddBy(rs.getString("ADD_BY"));
				line.setAddDate(rs.getString("ADD_DATE"));
				line.setAddTime(rs.getString("ADD_TIME"));
				line.setUpdBy(rs.getString("UPD_BY"));
				line.setUpdDate(rs.getString("UPD_DATE"));
				line.setUpdTime(rs.getString("UPD_TIME"));
				line.setActiveFlag(rs.getString("ACTIVE_FLAG"));
			}
		}catch(SQLException sqlE){
			sqlE.printStackTrace();
		}finally{
			DbPool.close(conn, pstmt, rs);
		}
		return line;
	}
}
